package top.kaoshanji.v1ch12a.controllers;

import org.springframework.web.bind.annotation.*;
import top.kaoshanji.v1ch12a.model.Purchase;
import top.kaoshanji.v1ch12a.repositories.PurchaseRepository;

import java.util.List;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/1 17:29
 */
@RestController
@RequestMapping("/purchase")
public class PurchaseController {

    private final PurchaseRepository purchaseRepository;

    public PurchaseController(PurchaseRepository purchaseRepository) {
        this.purchaseRepository = purchaseRepository;
    }

    @PostMapping("/addPurchase")
    public String addPurchase(@RequestBody Purchase purchase) {
        purchaseRepository.savePurchase(purchase);
        return "....";
    }

    @GetMapping("/getPurchaseList")
    public List<Purchase> getPurchaseList() {
        return purchaseRepository.queryPurchaseList();
    }

}
